//logs.js
Page({
  data: {
    testText: '测试文本测试文本测试文本测试文本测试文本试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本',
    giveAlike: '3',
    commentOn: '2',
    checkSite: '',
    list: "",
    INDEX:''
  },
  goPageSummer: function () {
    wx.navigateTo({
      url: '/pages/summer/summer'
    })
  },

  likeup: function (e) {
    var that = this
    var scenicId = e.currentTarget.dataset.iddd
    var clockinid = e.currentTarget.dataset.id
    console.log(clockinid)
    wx.request({
      url: 'http://120.25.151.125:8080/travel/scenic/likeUpClockInList',
      data:{
        clockInId:clockinid,
        scenicId:scenicId
      },
      method:'GET',
      header:{
        'Content-Type': 'application/json'
      },
      success:function(res){
        for(let i=0;i<res.data.length;i++){
          if(clockinid == res.data[i].clockId){
            console.log(res.data[i].clockId)
            that.setData({
              INDEX:i
            })
            console.log(i)
          }
        }
        console.log(res.data[that.data.INDEX].likeCount)
        that.setData({
          ["list["+that.data.INDEX+"].likeCount"]:res.data[that.data.INDEX].likeCount
        })
      }
  })
  
  
},

  showImg: function (e) {
    var src = e.currentTarget.dataset.src
    var imgUrl = e.currentTarget.dataset.imgurls
    wx.previewImage({
      urls: imgUrl,
      current: src,
    })
  },
  onLoad: function () {
    const that = this

    wx.request({
      url: 'http://120.25.151.125:8080/travel/scenic/clockInList',
      data: {},
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        //将获取到的图片地址由字符串形式转变为数组形式
        let data = res.data;
        for(let item of data){
          let _imgUrl = item.imgUrl;
          console.log(_imgUrl)
          item.imgUrl = _imgUrl.split(",");
        }
        //将获取到的json数据，存在名字叫list的这个数组中
        that.setData({
          list: data
          //res代表success函数的事件对，data是固定的，list是数组
        })
        console.log(res)
      }
    })
  },

})